package pl.com.hme.kody.pocztowe.ui;

import pl.com.hme.kody.pocztowe.R;
import pl.com.hme.kody.pocztowe.util.AnalyticsUtils;
import android.content.Intent;
import android.os.Bundle;
import android.os.StrictMode;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;

public class HomeActivity extends FragmentActivity  {

    private static final String TAG = "HomeActivity";
	private FragmentManager mFragmentManager;

	@Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        
        StrictMode.enableDefaults();
        
        setContentView(R.layout.activity_main);

        AnalyticsUtils.getInstance(getApplicationContext()).trackPageView("/Main");

        //Intent intent = new Intent(Intent.ACTION_RUN, null, this, CodeQueryService.class);
        //intent.putExtra(CodeQueryService.EXTRA_COMMAND_STRING, CodeQueryService.COMMAND_START_SERVICE);
        //startService(intent);        
    }

    @Override
	protected void onResume() {
		super.onResume();
		
		mFragmentManager = getSupportFragmentManager();
		boolean isVisible = mFragmentManager.findFragmentById(R.id.fragment_main).isVisible();
		Log.d(TAG, "onResume, Fragment is visible: " +isVisible);
	}
    
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.options_menu, menu);
        super.onCreateOptionsMenu(menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.about:
            Intent aboutIntent = new Intent(this, AboutActivity.class);
            startActivity(aboutIntent);
            return true;
        }

        return false;
    }
}